﻿@{
    ViewBag.Title = "RSettingForm";
    Layout = "~/Views/Shared/_LayoutIndex.cshtml";
}

<script>
    var MarryInfoText = "";
    var Data = [];
    $(function () {
        GetGrid();
        Initial();
    });

    function Initial() {
        $("#MarryInfo").ComboBox({
            data: [{ "key": "1", "value": "未婚无子女" }, { "key": "8", "value": "未婚有子女" }, { "key": "2", "value": "已婚无子女" }, { "key": "3", "value": "已婚有子女" }, { "key": "4", "value": "离婚、离异无子女" }, { "key": "5", "value": "离婚、离异有子女" }, { "key": "6", "value": "丧偶无子女" }, { "key": "7", "value": "丧偶有子女" }],
            id: "key",
            text: "value",
            description: "=选择状婚姻状况=", 
            click: function (item) {
            }
        });
        $("#IsPermant").ComboBox({
            data: [{ "key": "1", "value": "是" }, { "key": "0", "value": "否" }, ],
            id: "key",
            text: "value",
            description: "=选择户籍状态=",
            height: "200px",
            click: function (item) {
            }
        });
    }
    //加载表格
    function GetGrid() {

        var selectedRowIndex = 0;
        var $gridTable = $('#gridTable2');
        $gridTable.jqGrid({
            url: "../../QualificationManage/FirstTrial/GetMaterialRuleList",
            datatype: "json",
            height: $(window).height() - 100,
            autowidth: true,
            multiselect: true,
            colModel: [
                { label: "Code", name: "Code", index: "Code", width: 80, align: "center", hidden: true },
                { label: "编号", name: "Sort", index: "Sort", width: 50, align: "center" },
                { label: "材料名称", name: "Name", index: "Name", width: 120, align: "center" },
                { label: "标准说明", name: "Description", Description: "Description", width: 300, align: "center" },
                
                {
                    label: "是否提交", name: "IsSubmit", index: "IsRequired", width: 80, align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        if (cellvalue == 1) {
                            return "是";
                        }
                        else {
                            return "否";
                        }
                    }
                },
                 {
                     label: "是否上传", name: "IsUpload", index: "IsUpload", width: 80, align: "center",
                     formatter: function (cellvalue, options, rowObject) {
                         if (cellvalue == 1) {
                             return "是";
                         }
                         else {
                             return "否";
                         }
                     }
                 },
                {
                    label: "是否有效", name: "EnabledMark", index: "EnabledMark", width: 80, align: "center",
                    formatter: function (cellvalue, options, rowObject) {
                        if (cellvalue == 1) {
                            return "是";
                        }
                        else {
                            return "否";
                        }
                    }
                },
               // { label: "示例图片", name: "DemoImage", index: "Area", width: 80, align: "DemoImage" },
                { label: "创建人", name: "CreateUserName", index: "CreateUserName", width: 80, align: "center" },
                { label: "创建时间", name: "CreateDate", index: "CreateDate", width: 80, align: "center" }
            ],
            viewrecords: true,
            rowNum: 1000,
            rownumbers: false,
            gridview: true,
            onSelectRow: function () {
                selectedRowIndex = $("#" + this.id).getGridParam('selrow');
            },
            gridComplete: function () {
                $("#" + this.id).setSelection(selectedRowIndex, false);
            },
        });

    }
    function AcceptClick() {
        var MarryInfo = $("#MarryInfo").attr('data-value');
        var IsPermant = $("#IsPermant").attr('data-value');
        var keyValue = $("#gridTable2").jqGridRowValue("Code");
        if (MarryInfo === "") {
            dialogMsg('未选择婚姻状况！', 0);
            return false;
        }
        if (IsPermant === "") {
            dialogMsg('未选择户籍状态！', 0);
            return false;
        }
        if (keyValue == "") {
            dialogMsg('至少选择一条数据！', 0);
            return false;
        }
        switch (MarryInfo) {
            case "1":
                MarryInfoText = "未婚";
                break;
            case "2":
                MarryInfoText = "已婚无子女";
                break;
            case "3":
                MarryInfoText = "已婚有子女";
                break;
            case "4":
                MarryInfoText = "离婚、离异无子女";
                break;
            case "5":
                MarryInfoText = "离婚、离异有子女";
                break;
        }
        if (!$('#MSG').Validform()) {
            return false;
        }
        $.SaveForm({
            url: "../../QualificationManage/FirstTrial/SaveQRMForm",
            param: { MarryInfo: MarryInfo, IsPermant: IsPermant, MarryInfoText: MarryInfoText, Data: JSON.stringify(keyValue) },
            loading: "正在保存数据...",
            success: function () {
                top.frames["MSettingRuleForm"].$("#gridTable").trigger("reloadGrid");
                dialogClose();
            }
        });
    }

</script>

<div class="titlePanel">
    <div class="title-search ">
        <table class="form" id="MSG">
            <tr>
                <td class="formTitle">婚姻状况：</td>
                <td class="formValue"><div style="width:200px;" id="MarryInfo" type="selectTree" isvalid="yes" checkexpession="NotNull" class="ui-select"></div></td>
                <td class="formTitle" style="padding-left:10px;">是否本地户籍：</td>
                <td class="formValue"><div style="width:200px;" id="IsPermant" type="selectTree" isvalid="yes" checkexpession="NotNull" class="ui-select"></div></td>
                <td></td>
            </tr>

        </table>

    </div>
</div>
<div class="gridPanel">
    <table id="gridTable2"></table>
</div>


